const HtmlWebpackPlugin = require('html-webpack-plugin'), path = require('path')

module.exports = {
  // 打包模式
  mode: 'development', //development   production,
  entry: {
	index: path.resolve(__dirname, './src/js/index.js')
  },
  output: {
	path: path.resolve(__dirname + '/dist'), // 打包到哪个文件夹下
	filename: 'js/[name].js'  // dist/js/xxx.js
  },
  module: {
	rules: [
	  {
		test: /\.js$/,
		loader: 'babel-loader',
		exclude: path.resolve(__dirname, 'node_modules')
	  },
	  {
		test: /\.css$/,
		use: [
		  'style-loader',
		  'css-loader'
		]
	  },
	  {
		test: /\.scss$/,
		use: [
		  'style-loader',
		  'css-loader',
		  'sass-loader' // 编译成css
		]
	  },
	  // 模板
	  {
		test: /\.tpl$/,
		loader: 'ejs-loader'
	  }
	]
  },
  plugins: [
    new HtmlWebpackPlugin({
	  filename: 'index.html', // 打包后的文件名
	  template: path.resolve(__dirname, './src/index.html'),
	  chunks: ['index'],
	  excludeChunks: ['node_modules']
    })
  ],
  devServer: {
	open: true,
	host: 'localhost',
	port: 3300
  }
}



